package com.type.TypingDetector;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;

public class AccelSettings extends Activity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.settingsmain);
        
        Button button = (Button) findViewById(R.id.button);
        final EditText et = (EditText) findViewById(R.id.edittext);
        final CheckBox cb = (CheckBox) findViewById(R.id.checkbox);
        final RadioButton rbRed = (RadioButton) findViewById(R.id.radio_red);
        final RadioButton rbBlue = (RadioButton) findViewById(R.id.radio_blue);
        
        
        button.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		Toast.makeText(AccelSettings.this, et.getText(), Toast.LENGTH_SHORT).show();
        	}
        });
        
        
        et.setOnKeyListener(new OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                // If the event is a key-down event on the "enter" button
                if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                    (keyCode == KeyEvent.KEYCODE_ENTER)) {
                  // Perform action on key press
                  Toast.makeText(AccelSettings.this, et.getText(), Toast.LENGTH_SHORT).show();
                  return true;
                }
                return false;
            }

        });
        
        cb.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		CheckBox box = (CheckBox)v;
        		if (box.isChecked()) {
        			Toast.makeText(AccelSettings.this, "You checked this, foo", Toast.LENGTH_SHORT).show();
        		}
        		else {
        			Toast.makeText(AccelSettings.this, "You unchecked this, foo", Toast.LENGTH_SHORT).show();
        		}
        	}
        });
        
        final OnClickListener radio_list = new OnClickListener() {
        	public void onClick(View v) {
        		RadioButton rbu = (RadioButton)v;
        		Toast.makeText(AccelSettings.this, rbu.getText(), Toast.LENGTH_SHORT).show();
        	}
        };
        
        rbRed.setOnClickListener(radio_list);
        rbBlue.setOnClickListener(radio_list);
	}
}
